﻿<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Language" content="UTF-8" />
<link href="../../../style.css" rel="stylesheet" type="text/css" />
<title>单笔查询接口</title>
</head>
<body style="text-align:left;">
<?PHP

if($_POST[submit]){

function kq_ck_null($kq_va,$kq_na){if($kq_va == ""){$kq_va="";}else{return '<'.$kq_na.'>'.$kq_va.'</'.$kq_na.'>';}}

$txnStatus=kq_ck_null($_POST[txnStatus],'txnStatus');

$reqXml = '<?xml version="1.0" encoding="UTF-8"?><MasMessage xmlns="http://www.99bill.com/mas_cnp_merchant_interface"><version>'.$_POST[version].'</version><QryTxnMsgContent><externalRefNumber>'.$_POST[externalRefNumber].'</externalRefNumber><refNumber>'.$_POST[refNumber].'</refNumber><txnType>'.$_POST[txnType].'</txnType><merchantId>'.$_POST[merchantId].'</merchantId><terminalId>'.$_POST[terminalId].'</terminalId>'.$txnStatus.'</QryTxnMsgContent></MasMessage>';


	$merchantId = "104110045112012";
	$certFileName = "D:/wamp/www/CNP1/php_demo/10411004511201290.pem";
	$certPassword = "vpos123";
	$url = 'https://sandbox.99bill.com:9445/cnp/query_txn';
	$user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
	 
	//echo "$reqXml";
	$loginInfo = array(	"Authorization: Basic " . base64_encode("104110045112012:vpos123"));

	$ch = curl_init();

	curl_setopt($ch, CURLOPT_URL,$url);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,2);
	curl_setopt($ch, CURLOPT_USERAGENT,$user_agent);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,FALSE);
	curl_setopt($ch, CURLOPT_CAINFO, $certFileName);
	curl_setopt($ch, CURLOPT_SSLCERT, $certFileName);
	curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $certPassword);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $reqXml); 
	curl_setopt($ch, CURLOPT_HTTPHEADER, $loginInfo);

	$tr2Xml=curl_exec($ch);
	
	
	echo "<html><body>结果：<br/>";//数据结果

	echo "<textarea rows=\"20\" cols=\"100\">".$reqXml."</textarea></br>";
	echo "<textarea rows=\"20\" cols=\"100\">".$tr2Xml."</textarea></br>";


     echo "</body></html>";
    
	if (curl_error($ch))
    printf("Error %s: %s", curl_errno($ch), curl_error($ch));
    curl_close ($ch);



}
?>


<h1>查询（单笔）</h1>
<form method=post action="" name="">
	<table cellspacing="18" cellpadding="0" border="0" class="center_table">
		<tr>
			<td>版本（version） <span class="">*</span> </td>
			<td><input type="text" name="version" value="1.0" /></td>
		</tr>
		
		<tr>
			<td>外部跟踪号externalRefNumber <span class="">*</span> </td>
			<td><input type="text" name="externalRefNumber"  value="02150000000400"  /></td>
		</tr>
		<tr>
			<td>系统参考号refNumber <span class="">*</span> </td>
			<td><input type="text" name="refNumber" value="000009389443" /></td>
		</tr>
		<tr>
			<td>交易类型txnType <span class="">*</span> </td>
			<td><input type="text" name="txnType" value="PUR" /></td>
		</tr>
		<tr>
			<td>商户编号merchantId <span class="">*</span></td>
			<td><input type="text" name="merchantId" value="104110045112012" /></td>
		</tr>
		<tr>
			<td>终端编号terminalId <span class="">*</span></td>
			<td><input type="text" name="terminalId" value="00002012" /></td>
		</tr>
		<tr>
			<td>交易状态 txnStatus (S : 成功 F : 失败)<span class=""></span></td>
			<td><input type="text" name="txnStatus" value="" /></td>
		</tr>		
		<tr>
			<td> </td>
			<td><input type="submit" name="submit" value="提交到快钱"  style="padding:10px 35px;font-weight:bold;font-family:arail"></td>
		</tr>
	</table>	
</form>
</body>
</html>